package cn.edu.scau.cmi.wujiaxian.exercise11;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;


public class MyWindow extends JFrame implements ActionListener{
	private static final long serialVersionUID = 4174621914605686809L;

	JButton button;
	MyDialog dialog;
	
	public MyWindow() {
		init();
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	void init() {
		button = new JButton("打开对话框");
		button.addActionListener(this);
		add(button, BorderLayout.NORTH);
		dialog = new MyDialog(this, "我是对话框");
		dialog.setModal(true);
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		dialog.setVisible(true);
		String string = dialog.getTitle();
		setTitle(string);
	}
	
}
